<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var num = prompt('请输入1-7之间的数字：');
        //接收的数据类型为字符串，需将字符串转为数字型
        num = parseInt(num);
        if(isNaN(num)){
            alert('你输入的数字有误！');
        }else{
            if(num >= 1 && num <= 7){
                switch(num){
                    case 1:
                        document.write('<h2>星期一</h2>');
                        break;
                    case 2:
                        document.write('<h2>星期二</h2>');
                        break;
                    case 3:
                        document.write('<h2>星期三</h2>');
                        break;
                    case 4:
                        document.write('<h2>星期四</h2>');
                        break;
                    case 5:
                        document.write('<h2>星期五</h2>');
                        break;
                    case 6:
                        document.write('<h2>星期六</h2>');
                        break;
                    case 7:
                        document.write('<h2>星期天</h2>');
                        break;
                    default:
                        document.write('你输入的数据类型有问题');
                }
            }else{
                alert('你输入的数字不在取值范围内！');
            }
        }
    </script>
</body>
</html>